package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.bussiness.domain.SysBusinessExpert;
import com.ruoyi.bussiness.domain.SysBusinessPortfolio;
import com.ruoyi.bussiness.service.ISysBusinessExpertService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 学者风采Controller
 *
 * @author ruoyi
 * @date 2024-01-23
 */
@RestController
@RequestMapping("/system/expert")
public class SysBusinessExpertController extends BaseController
{
    @Autowired
    private ISysBusinessExpertService sysBusinessExpertService;

    /**
     * 查询学者风采列表
     */
    @PreAuthorize("@ss.hasPermi('system:expert:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBusinessExpert sysBusinessExpert)
    {
        startPage();
        List<SysBusinessExpert> list = sysBusinessExpertService.selectSysBusinessExpertList(sysBusinessExpert);
        return getDataTable(list);
    }

    /**
     * 导出学者风采列表
     */
    @PreAuthorize("@ss.hasPermi('system:expert:export')")
    @Log(title = "学者风采", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBusinessExpert sysBusinessExpert)
    {
        List<SysBusinessExpert> list = sysBusinessExpertService.selectSysBusinessExpertList(sysBusinessExpert);
        ExcelUtil<SysBusinessExpert> util = new ExcelUtil<SysBusinessExpert>(SysBusinessExpert.class);
        util.exportExcel(response, list, "学者风采数据");
    }

    /**
     * 获取学者风采详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:expert:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(sysBusinessExpertService.selectSysBusinessExpertById(id));
    }

    /**
     * 新增学者风采
     */
    @PreAuthorize("@ss.hasPermi('system:expert:add')")
    @Log(title = "学者风采", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBusinessExpert sysBusinessExpert)
    {
        return toAjax(sysBusinessExpertService.insertSysBusinessExpert(sysBusinessExpert));
    }

    /**
     * 修改学者风采
     */
    @PreAuthorize("@ss.hasPermi('system:expert:edit')")
    @Log(title = "学者风采", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBusinessExpert sysBusinessExpert)
    {
        return toAjax(sysBusinessExpertService.updateSysBusinessExpert(sysBusinessExpert));
    }

    /**
     * 删除学者风采
     */
    @PreAuthorize("@ss.hasPermi('system:expert:remove')")
    @Log(title = "学者风采", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(sysBusinessExpertService.deleteSysBusinessExpertByIds(ids));
    }

    /**
     * 上移下移政策
     */
    @PreAuthorize("@ss.hasPermi('system:expert:edit')")
    @Log(title = "学者风采", businessType = BusinessType.UPDATE)
    @PutMapping("/moveUpOrDown")
    public AjaxResult moveUpOrDown(@RequestBody SysBusinessExpert entity)
    {
        return sysBusinessExpertService.moveUpOrDown(entity);
    }

    /**
     * 置顶 置底政策
     */
    @PreAuthorize("@ss.hasPermi('system:expert:edit')")
    @Log(title = "学者风采", businessType = BusinessType.UPDATE)
    @PutMapping("/pinToTopOrEnd")
    public AjaxResult pinToTopOrEnd(@RequestBody SysBusinessExpert entity)
    {
        return sysBusinessExpertService.pinToTopOrEnd(entity);
    }
}
